<template>
	<view class="myNote">
		<Article :data="articleData"></Article>
	</view>
</template>

<script>
import Article from '../../../index/article/article.vue'
export default {
	name: 'note',
	components: {
		Article
	},
	props: {
		value: {
			type: Number,
			default: 1
		}
	},
	data(){
		return {
			searchForm: {
				pageNumber: 1, // 当前页数
			    pageSize: 6, // 页面大小
			},
			pages: 0,
			articleData: [],
		}
	},
	created() {
		console.log("create");
		let _this = this;
		this.getList().then(res => {
			_this.articleData = res.records;
			_this.pages = res.pages;
		});
	},
	onReachBottom() {
		console.log("reachbottom");
		let _this = this;
		_this.searchForm.pageNumber++;
		if (_this.searchForm.pageNumber> _this.pages) {
			uni.hideNavigationBarLoading();
			uni.showToast({
				title: '暂无更多数据',
				icon: 'none'	
			})
		} else {
			_this.getList().then(res => {
				_this.articleData = _this.articleData.concat(res.records);
				uni.hideNavigationBarLoading();
			});
		}
	},
	methods: {
		getList(){
			let _this = this;
			return new Promise((resovle,reject) => {
				_this.$api.getMyArticle(this.searchForm).then(res => {
					resovle(res.result)
				}).catch(err => {
					reject(err);
				})
			})
			
		},
		loadData(){
			this.getList();
		}
	}
}
</script>

<style>
	.myNote {
		margin-top: 10rpx;
	}
</style>